% !TEX program = xelatex
%-*- coding: UTF-8 -*-

\PassOptionsToPackage{quiet}{fontspec}
\documentclass[no-math]{masterthesis}
\usepackage{lipsum, zhlipsum}    % for test use
% \usepackage{layout, showframe}   % for test use
% == packages
\usepackage{amsmath, mathtools, upgreek}
\usepackage{graphicx, tikz, pgfplots}
\usepackage{threeparttable, booktabs, longtable, multirow, dcolumn}
\usepackage{fancyvrb}
\usepackage[ruled,linesnumbered]{algorithm2e} %伪代码
\usepackage{bm} %希腊字母加粗斜体
\usepackage{makecell} % 表内换行
\usepackage{longtable} %分页表格
\usepackage{nomencl}
%选择题
\usepackage{ifthen}
\usepackage{array}
% == input
\bjutset{%
  clc            = {TU311},      % 中文图书分类号
  udc            = {004},        % 十进制分类号
  schoolcode     = {10005},      % 学校编号
  secretlevel    = {公开},       % 密级
  studentid      = {S202300000}, % 学号
  % -- 中文信息
  ctitle         = {\masterthesis\,\version\,——北京工业大学硕士专业论文{\LaTeX}模板},
  cauthor        = {王皓}, 
  cdiscipline    = {电子科学与技术},   % 学科  
  cmajor         = {电子与通信工程},   % 研究方向
  cdegree        = {硕士专业}, 
  csupervisor    = {孙光民}, %第一导师
  csupervisortwo    = {张三}, %第二导师
  csupervstitle  = {教授}, %第一导师职称
  csupervstitletwo  = {研究员}, %第二导师职称
  ccollege       = {信息学部},  
  cdate          = {\the\year~年\the\month~月},
  corganization  = {北京工业大学},
  % -- 英文信息
  etitle         = {\masterthesis: \LaTeX-based Template for Doctoral Dissertation of Beijing University of Technology},
  edegree        = {Doctor of Engineering},
  emajor         = {Electronic and Communication Engineering},
  eauthor        = {WANG Hao},
  esupervisor    = {SUN Guangmin},
  esupervisortwo    = {ZHANG San}, %英文第二导师职称
  ecollege       = {Faculty of Information Technology},
  edate          = {\today}
}

%                    *********************
%                     **** 四项选择题 ****
%                    *********************
%      用法: \choice{ }{ }{ }{ }
 
\newcommand{\fourch}[4]{%~\hfill(\qquad)\\
\begin{tabular}{*{4}{@{}p{0.25\textwidth}}}(A)~#1 & (B)~#2 & (C)~#3 & (D)~#4\end{tabular}}
\newcommand{\twoch}[4]{%~\hfill(\qquad)\\
\begin{tabular}{*{2}{@{}p{0.5\textwidth}}}(A)~#1 & (B)~#2\end{tabular}\\\begin{tabular}{*{2}{@{}p{0.5\textwidth}}}(C)~#3 & (D)~#4\end{tabular}}
\newcommand{\onech}[4]{%~\hfill(\qquad)\\
(A)~#1 \\ (B)~#2 \\ (C)~#3 \\ (D)~#4}
 
\newlength\widthcha
\newlength\widthchb
\newlength\widthchc
\newlength\widthchd
\newlength\widthch
\newlength\tabmaxwidth
\setlength\tabmaxwidth{1\textwidth}
\newlength\fourthtabwidth
\setlength\fourthtabwidth{0.25\textwidth}
\newlength\halftabwidth
\setlength\halftabwidth{0.5\textwidth}
 
\newcommand{\choice}[4]{\settowidth\widthcha{AM.#1}\setlength{\widthch}{\widthcha}
    \settowidth\widthchb{BM.#2}
    \ifthenelse{\widthch<\widthchb}{\setlength{\widthch}{\widthchb}}{}
    \settowidth\widthchb{CM.#3}
    \ifthenelse{\widthch<\widthchb}{\setlength{\widthch}{\widthchb}}{}
    \settowidth\widthchb{DM.#4}
    \ifthenelse{\widthch<\widthchb}{\setlength{\widthch}{\widthchb}}{}
    \ifthenelse{\widthch<\fourthtabwidth}{\fourch{#1}{#2}{#3}{#4}}
    {\ifthenelse{\widthch<\halftabwidth\and\widthch>\fourthtabwidth}{\twoch{#1}{#2}{#3}{#4}}
        {\onech{#1}{#2}{#3}{#4}}}}

\begin{document}
\makecover                          % -- 封面（PDF使用，打印版无需）
\maketitle                          % -- 内封           
\makestate                          % -- 声明页
\frontmatter                        %% ==== 前页 ====
\include{./tex/abstract}            % -- 摘要，关键词
\makebitoc                          % -- 目录
%\listoffigures                      % -- （可选）插图目录
%\listoftables                       % -- （可选）表格目录
%\printnomenclature                  % -- （可选）术语表
\mainmatter                         %% ==== 正文 ====
\include{./tex/chapter01}           % -- 第1,2,...章
\include{./tex/chapter02}           % -- 
\include{./tex/conclusion}          % -- 结论
\makebib{./ref/reference}           % -- 参考文献，GB/T7714-2015
\appendix                           %% ==== 附录 ====
\include{./tex/appendix_a}          % -- 附录A,B,...
\include{./tex/appendix_b}          % --
\backmatter                         %% ==== 附页 ====
%\include{./tex/publication}         % -- 发表文献
\include{./tex/acknowledgement}     % -- 致谢
\end{document}
